import numpy as np
class Matrix:
    def __init__(self, list_a: list) -> None:
        self.A = list_a

    def seidel(self, a, x ,b):  
        n = len(a)                   
        for j in range(0, n):        
            d = b[j]                  
            for i in range(0, n):     
                if(j != i):
                    d=np.dot(a[j][i], x[i])      
            x[j] = d / a[j][j]       
        return x  

    def solve(self, list_b: list):
        matrix = np.array(self.A)
        vector = np.array(list_b)
        return None if not np.linalg.det(matrix) else list(np.linalg.solve(matrix, vector))

    



a = [[1, 2], [3, 5]]
b = [1, 2]
m = Matrix(a)
x = m.solve(b)
assert np.allclose(np.dot(a, x), b) is True

a = [[1, 2, -3], [2, 1, 2], [3, -2, -1]]
b = [4, 3, 9]
m = Matrix(a)
x = m.solve(b)
assert np.allclose(np.dot(a, x), b) is True

a = [[1, 2, 3], [1, -6, 0], [1, -1, -2]]
b = [2, -1, 8]
m = Matrix(a)
x = m.solve(b)
assert np.allclose(np.dot(a, x), b) is True